package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.util.HashMap;
import java.util.Map;

import javax.print.attribute.standard.Media;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.DefaultListModel;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JTree;
import javax.swing.ScrollPaneLayout;
import javax.swing.border.LineBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.DefaultMutableTreeNode;

@SuppressWarnings("serial")
public class GUI extends JFrame{

	public GUI(){
		this.setTitle("FileManager");
		this.setLayout(new BorderLayout());
		
		JScrollPane filePanel = new JScrollPane();
		
		DefaultListModel devModel = new DefaultListModel();
		
		JList devList = new JList(devModel);
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		devModel.addElement("asdasd");
		
		DefaultListModel locModel = new DefaultListModel();
		
		JList locList = new JList(locModel);
		
		locModel.addElement("kkkk");
		locModel.addElement("kkkk");
		locModel.addElement("kkkk");
		locModel.addElement("kkkk");
		locModel.addElement("kkk");
		
		
		
		/*JPanel mediaFileContPanel = new JPanel();
		mediaFileContPanel.setLayout(new GridLayout(2,1));
		*/
		
		DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
		DefaultMutableTreeNode child1 = new DefaultMutableTreeNode("DEVICES");
		DefaultMutableTreeNode child5 = new DefaultMutableTreeNode("HD1");
		DefaultMutableTreeNode child6 = new DefaultMutableTreeNode("USB1");
		root.add(child1);
		child1.add(child5);
		child1.add(child6);
		DefaultMutableTreeNode child2 = new DefaultMutableTreeNode("LOCATIONS");
		DefaultMutableTreeNode child3 = new DefaultMutableTreeNode("desktop");
		DefaultMutableTreeNode child4 = new DefaultMutableTreeNode("downloads");
		root.add(child2);
		child2.add(child3);
		child2.add(child4);
		
		JTree tree = new JTree(root);
		tree.setRootVisible(false);
		
		
		JScrollPane mediaPanel = new JScrollPane(tree);
		mediaPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		mediaPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		mediaPanel.setViewportBorder(new LineBorder(Color.BLACK));
		mediaPanel.setLayout(new ScrollPaneLayout());
		
		
		
		
		/*mediaFileContPanel.add(devList);
		devList.setBorder(BorderFactory.createTitledBorder("DEVICES"));
		mediaFileContPanel.add(locList);
		locList.setBorder(BorderFactory.createTitledBorder("LOCATIONS"));*/
		
		

		JPanel navigationPanel = new JPanel();
		JPanel navigationViewPanel = new JPanel();
		JPanel navigationViewTypePanel = new JPanel();
		JPanel navigationPathPanel = new JPanel();
		
		JSplitPane media_filePanel = new JSplitPane();
		media_filePanel.setLeftComponent(mediaPanel);
		media_filePanel.setRightComponent(filePanel);
		media_filePanel.setDividerLocation(200);
		media_filePanel.setDividerSize(2);
		media_filePanel.setMinimumSize(new Dimension(400,400));
		
		JButton forward = new JButton();
		ImageIcon forward_ico = new ImageIcon("resource/gui_icons/forward.png");
		forward.setIcon(forward_ico);
		
		//JLabel test = new JLabel("aasda");
		//test.setIcon(forward_ico);
		//locModel.addElement(test);
		
		
		JButton back = new JButton();
		ImageIcon back_ico = new ImageIcon("resource/gui_icons/back.png");
		back.setIcon(back_ico);
		
		JButton uplevel = new JButton();
		ImageIcon up_ico = new ImageIcon("resource/gui_icons/up.png");
		uplevel.setIcon(up_ico);
		
		
		JButton listView = new JButton("");
		ImageIcon list_view_ico = new ImageIcon("resource/gui_icons/list_view.png");
		listView.setIcon(list_view_ico);
		
		JButton iconView = new JButton("");
		ImageIcon icon_view_ico = new ImageIcon("resource/gui_icons/icon_view.png");
		iconView.setIcon(icon_view_ico);
		
		
		JTextField pathTextField = new JTextField("file://hd1/bin/test",30);
		
		
		
		GridLayout navigationGrid = new GridLayout(2, 1);
		navigationPanel.setLayout(navigationGrid);
		navigationPanel.add(navigationViewPanel);
		navigationPanel.add(navigationPathPanel);
		navigationPanel.setMinimumSize(new Dimension(500, 300));
		
		navigationViewPanel.setLayout(new BorderLayout());
		navigationViewTypePanel.setLayout(new FlowLayout());
		
		
		navigationViewPanel.add(navigationViewTypePanel,BorderLayout.CENTER);
		navigationViewTypePanel.add(listView);
		navigationViewTypePanel.add(iconView);
		
		
		navigationPathPanel.setLayout(new FlowLayout());
		navigationPathPanel.add(back);
		navigationPathPanel.add(forward);
		navigationPathPanel.add(pathTextField);
		navigationPathPanel.add(uplevel);
		
		
		
		this.add(navigationPanel,BorderLayout.NORTH);
		this.add(media_filePanel,BorderLayout.CENTER);
		this.setMinimumSize(new Dimension(600,400));
		this.pack();
		this.setSize(800,500);
		this.setVisible(true);
		
		/*Map<Object, Icon> icons = new HashMap<Object, Icon>();
		icons.put("kkkk",icon_view_ico);
		icons.put("kkk", list_view_ico);
		IconListRenderer g = new IconListRenderer(icons);
		locList.setCellRenderer(g);
		*/
		
		
		
	}
	
	
	public static void main(String[] args){
		
		GUI g = new GUI();
		
		
	}
	
}


